From d80953666edfc4f8ad5682e5c06cfe81d38d03cb Mon Sep 17 00:00:00 2001 From: Morten Welinder Date: Mon, 7 Nov 2011 13:10:24 -0500 Subject: [PATCH] Print preview: make cancel work This makes cancels of a print preview work in the same way it works for non-previews, i.e., the operation stops at the next page boundary. https://bugzilla.gnome.org/show_bug.cgi?id=662160 --- gtk/gtkprintoperation.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/gtk/gtkprintoperation.c b/gtk/gtkprintoperation.c index b6fa95d4c6..87f4d4ebbd 100644 --- a/gtk/gtkprintoperation.c +++ b/gtk/gtkprintoperation.c @@ -550,11 +550,19 @@ preview_print_idle_done (gpointer data) op = GTK_PRINT_OPERATION (pop->preview); cairo_surface_finish (pop->surface); - /* Surface is destroyed in launch_preview */ - _gtk_print_operation_platform_backend_launch_preview (op, - pop->surface, - pop->parent, - pop->filename); + + if (op->priv->status == GTK_PRINT_STATUS_FINISHED_ABORTED) + { + cairo_surface_destroy (pop->surface); + } + else + { + /* Surface is destroyed in launch_preview */ + _gtk_print_operation_platform_backend_launch_preview (op, + pop->surface, + pop->parent, + pop->filename); + } g_free (pop->filename); @@ -580,10 +588,14 @@ preview_print_idle (gpointer data) op = GTK_PRINT_OPERATION (pop->preview); priv = op->priv; - if (priv->page_drawing_state == GTK_PAGE_DRAWING_STATE_READY) { - if (!pop->pages_data->initialized) + if (priv->cancelled) + { + done = TRUE; + _gtk_print_operation_set_status (op, GTK_PRINT_STATUS_FINISHED_ABORTED, NULL); + } + else if (!pop->pages_data->initialized) { pop->pages_data->initialized = TRUE; prepare_data (pop->pages_data); -- 2.30.2